from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder


def test():
    prompt = ChatPromptTemplate.from_messages(
        [
            (
                "system",
                "You are a helpful assistant. Answer all questions to the best of your ability.",
                # 系统消息：你是一个乐于助人的助手，请尽你所能回答所有问题
            ),
            MessagesPlaceholder(variable_name="messages"),  # 消息占位符，使用变量名“messages”来占位
        ]
    )


def test2():
    # 基本聊天模板
    system_message = '你是一位{role}专家，擅长回答{domain}领域的问题。'
    human_message = '{question}'

    chat_prompt = ChatPromptTemplate.from_messages([
        ("system", system_message),
        ("human", human_message)
    ])

    # 格式化聊天模板
    formatted_messages = chat_prompt.format_messages(
        role="医疗健康",
        domain="营养学",
        question="每天应该摄入多少蛋白质？"
    )
    print(formatted_messages)
